The Threads Viewer

The application is now stopped at the second breakpoint. Now, let the application run its course to start-up before taking a look at the threads.
In the Source Editor

Press Cont.
The application window appears in the top left-hand corner of your screen. Check to see that it isn't hidden by any other windows.

2. Close the Source Editor to get a less cluttered screen.

In the Variable Viewer

- To start the Threads Viewer, choose Tools > Threadsview.
You can also start the Threads Viewer from the Debugger Command Line window, by typing

vt (short for viewthreads ) at the prompt.
In the Threads Viewer
The first line in the Threadgroups column is highlighted. This means you see only the information that applies to this thread group.

To see all the threads, highlight each threadgroup by clicking on it.
To see only the threads specific to the application itself, deselect all the highlighted items in the Threadgroups column, except the last one, by clicking on them.
You now see the threads generated by the application itself.

Watching a thread
Make sure you can see both the Threads Viewer and the Back Office System window on your screen.
In the Threads column of the Threads Viewer, there are only 3 items at present (this may vary, depending on your operating system).
In the Back Office System window, there is a button on the left called Start. This button starts a timer thread, which increments the date by the number of days set on the right. And this is the new thread you will start.

In the Back Office System window, press Start.
The time, as can be seen above the button, starts incrementing by one day per second.
To update the Threads column in the Threads Viewer, press the Threads button at the top of the Threads column.
A new item is added to the list:

Thread-2 cond. waiting (the name of the thread and its condition, in this case: waiting).
Note that you can also choose an automatic update option from the Threads Viewer's View menu.
Testing run-time changes in variables
You can change the contents of simple variables and test the resulting changes while the program is running in the debug mode. We will test changes in the time increment value of the simulated clock.

In the Threads column, highlight the new thread that appeared when you started the timer thread.
In the Stackframes column, highlight the first item.
The local variables of the SimulationClock class appear in the last column of the Threads Viewer.
To look at these variables, double-click on the item in the last column.

In the Variable Viewer
We will use the Variable Viewer to do a run-time test of a new value for the time increment, so please make sure you can see both the Variable Viewer and the Back Office System window.

In the Variable Viewer, expand the node of the object.
You can now see, among other things, the variable:

private long increment = 86400000
Double-click on this variable.
The variable value appears highlighted in the Variable Field at the bottom of the tool. The value represents one day. If you add a zero to this number, you will have the value for 10 days.
Click into the Variable field and add a zero to the value, then hit <Return> .
Take a look at the Back Office System window. The time value in the Back Office System window is now incremented by 10 days, instead of 1.
Note that this value is not persistent, and applies only for this debugging session.

Closing the debugger
To close the debugger, choose Tools > Close Tool from its menu.
Review
This was the last chapter of the edit/compile/debug part. In this introduction to the sniffjdb debugger, you learnt how to:

- set the SNiFF+ Java debugger (sniffjdb) in your Preferences
- set breakpoints
- watch variables
- watch threads
- make run-time changes to a simple variable and watch the results

What's next
Later in the tutorial, you will create a new working environment for a new team member. Since your team member needs access to the most current source code, you must check in the files you've modified. To do so:
In the Project Editor

Choose View > Select Project Set > MySources.
In the File Status drop-down, choose Writable.
Only writable files in the project set are displayed.
Choose File > Select All and then File > Check In.

In the Check In dialog

In the Change Set field, enter a name for the change set e.g.,

second_file_set .
In the Comment field, enter a comment e.g., modified files .
Press Ok.
The files in the File List are no longer in bold typeface. This means that they are now read- only.
Close all tools except for the Launch Pad.